package com.banggood.upms.bean.exception;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xuchuangfeng
 * @date 2017/5/5
 */
public enum ExceptionEnum {

    SYSTEM_CODE_DUPLICATED(1000, "系统code不允许重复！"),
    SYSTEM_ID_CANT_BE_NULL(1001, "必须指定系统进行权限分配！"),

    INVALIDATE_USER_SCOPE(1005, "无效的用户一级域！"),
    USER_SCOPE_ALREADY_EXIST(1006, "用户域已经存在！"),
    USER_PERM_SEARCH_PARM_INVALID(1008, "用户权限搜索参数异常！"),
    USER_NOT_EXISTS(1009, "用户不存在！"),

    // Tree
    TREE_TYPE_EXISTS(2000, "树类别已经存在！"),
    PARENT_NODE_NOT_EXIST(2001, "父级节点不存在！"),
    INVALID_DEPARTMENT_ID(2002, "无效的部门ID"),
    TREE_TYPE_CANT_BE_NULL(2003, "必须指定树类型节点分配！"),
    MISSING_TREE_TYPE(2004, "没有传入树类型！"),
    ROOT_NODE_HAS_PARENT_NODE(2005, "根节点不可拥有父级节点ID！"),
    TREE_TYPE_INCONSISTENT(2006, "父子节点类别不同！"),
    TREE_TYPE_NOT_EXISTS(2007, "树类别不存在！"),
    NODE_NOT_EXISTS(2008, "树节点不存在！"),
    MISSING_TREE_ID(2009, "必须指定树节点ID！"),
    NODE_CODE_ALREADY_EXISTS(2010, "node code已经存在！"),
    // Tree tree
    FORBIDDEN_FROM_TREE_TYPE(2011, "被分配节点的树类型只能是岗位"),

    // SystemPo
    REQUEST_SYSTEM_META_ERROR(3000, "获取系统元数据异常，请检测填入接口是否正确！"),
    SYSTEM_NOT_EXISTS(3001, "系统不存在或已删除！"),

    // User
    DUPLICATED_ACCOUNT_NAME(4000, "账号已经存在！"),


    OPERATION_FAILED(5000, "操作失败！");

    private static Map<Integer, ExceptionEnum> valueMap = new HashMap<>();

    static {
        for(ExceptionEnum exception : ExceptionEnum.values()) {
            valueMap.put(exception.code, exception);
        }
    }
    private int code ;
    private String message ;

    ExceptionEnum(int code , String message){
        this.code = code ;
        this.message = message ;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
